import request from '@/axios'

export interface SysAuthority {
  authorityId?: number
  authorityName: string
  authorityCode: string
  authorityType?: string
  createUserId?: number
  createUserName?: string
  createTime?: string
  updateUserId?: number
  updateUserName?: string
  updateTime?: string
}

export interface AuthorityQueryParams {
  pageNum?: number
  pageSize?: number
  authorityName?: string
  authorityCode?: string
  authorityType?: string
}

// 分页查询权限列表
export const getAuthorityList = (params: AuthorityQueryParams) => {
  return request.post({ url: '/api/system/authority/list', data: params })
}

// 查询所有权限列表（不分页）
export const getAllAuthorities = () => {
  return request.get({ url: '/api/system/authority/all' })
}

// 根据ID查询权限详情
export const getAuthorityDetail = (id: number) => {
  return request.get({ url: `/api/system/authority/${id}` })
}

// 新增权限
export const addAuthority = (data: SysAuthority) => {
  return request.post({ url: '/api/system/authority', data })
}

// 更新权限
export const updateAuthority = (id: number, data: SysAuthority) => {
  return request.put({ url: `/api/system/authority/${id}`, data })
}

// 删除权限
export const deleteAuthority = (id: number) => {
  return request.delete({ url: `/api/system/authority/${id}` })
}

// 批量删除权限
export const batchDeleteAuthority = (ids: number[]) => {
  return request.delete({ url: '/api/system/authority/batch', data: ids })
}
